//
//  VideoEditorViewController.m
//  BTAVEditor
//
//  Created by XMac on 2019/11/26.
//  Copyright © 2019 XMac. All rights reserved.
//

#import "VideoEditorViewController.h"
#import "AVAssetViewController.h"
#import "AVRecordViewController.h"
#import "AVCompositionViewController.h"
@interface VideoEditorViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (weak, nonatomic) IBOutlet UITableView *selectTableView;
@property (strong, nonatomic) NSArray<NSDictionary<NSString *,NSString *> *> *titles;

@end

@implementation VideoEditorViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self configData];
    
    [self configUI];
}

-(void)configData{
    
    
    self.titles = @[@{@"视频播放":@"AVAssetViewController"},
                    @{@"视频录制":@"AVRecordViewController"},
                    @{@"视频剪辑":@"AVCompositionViewController"},
                    ];
}

-(void)configUI{
    self.title = @"选择功能";
    
    [self.selectTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
}

///MARK: tableview delegate
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.titles.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    NSDictionary *temp = self.titles[indexPath.row];
    NSString *key = temp.allKeys.firstObject;
    cell.textLabel.text = key;
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    NSDictionary *temp = self.titles[indexPath.row];
    NSString *className = temp.allValues.firstObject;
    
    UIViewController *vc = [NSClassFromString(className) alloc] ;
    vc = [vc initWithNibName:className bundle:nil];
    [self.navigationController pushViewController:vc animated:YES];
}


@end
